﻿# -- TxtIo_m.py
"""
    Copyright 2013 J. Kent Harbaugh

    This file is part of Raddel.

    Raddel is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Raddel is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Raddel.  If not, see <http://www.gnu.org/licenses/>.
"""



def GetInt(Prompt):
    while true:
        inp=GetStr(Prompt)
        try:
            num=int(inp)
        except ValueError:
            continue
        return num



def GetOpt(Options,Prompt='? '):
    for idxZip in zip(range(len(Options)),Options):
        print(str(idxZip[0])+' = '+str(idxZip[1]))
    while true:
        num=GetInt(Prompt)
        if 0<=num and num<len(Options):
            return num



def GetStr(Prompt):
    return input(Prompt)



# -- TxtIo_m.py
